"use strict";var _createClass=function(){function n(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),e}}(),_get=function e(t,r,n){null===t&&(t=Function.prototype);var i=Object.getOwnPropertyDescriptor(t,r);if(void 0===i){var o=Object.getPrototypeOf(t);return null===o?void 0:e(o,r,n)}if("value"in i)return i.value;var s=i.get;return void 0!==s?s.call(n):void 0};function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}!function(s,t){var r=(_inherits(e,s.Quiz),_createClass(e,[{key:"loadEvents",value:function(){var o=this;_get(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"loadEvents",this).call(this),this.$wrapper.on("click.startSwiperQuiz",".wq_beginQuizSwiperCtr",function(e){e.preventDefault(),o.$wrapper.find(".wq_swiperQuizPreviewInfoCtr").fadeOut("fast",function(){o.$wrapper.find(".wq_QuestionWrapperSwiper").fadeIn(),window.dispatchEvent(new Event("resize"))})}),this.$wrapper.find(".wq-swiper").wqTinder({containerClass:"wq-swiper",cardsClass:"wq-swiper-items",cardClass:"wq-swiper-item",likeButtonClass:"wq-swiper-like-btn",dislikeButtonClass:"wq-swiper-dislike-btn",onLike:function(e){var t=e.dataset.index,r=o.$wrapper.find('.wq-result[data-index="'+t+'"]');r.find(".wq-result-content").append('<div class="wq-user-vote wq-positive-vote userVote positiveVote">'+s.i18n.youVoted+' <i class="sprite sprite-check"></i></div>');var n=r.find(".wq-votes-up-count").text();-1===n.indexOf("K")&&r.find(".wq-votes-up-count").text(parseInt(n)+1);var i=r.attr("data-id");o.questions[t].votesUp++,o.tracker[i]=1},onDislike:function(e){var t=e.dataset.index,r=o.$wrapper.find('.wq-result[data-index="'+t+'"]');r.find(".wq-result-content").append('<div class="wq-user-vote wq-negative-vote userVote negativeVote">'+s.i18n.youVoted+' <i class="sprite sprite-times"></i></div>');var n=r.find(".wq-votes-down-count").text();-1===n.indexOf("K")&&r.find(".wq-votes-down-count").text(parseInt(n)+1);var i=r.attr("data-id");o.questions[t].votesDown++,o.tracker[i]=0},onEnd:function(){var e=this,n=[];function t(){e.reset(),o.$wrapper.find(".wq-user-vote").remove(),o.$wrapper.find(".wq-results").fadeOut("slow",function(){o.$wrapper.find(".wq-questions").fadeIn(),window.dispatchEvent(new Event("resize"))})}o.questions.forEach(function(e){var t=e.votesUp||0,r=e.votesDown||0;n.push({id:e.id,votes:t-r})}),n.sort(function(e,t){return t.votes-e.votes}),n.forEach(function(e,t){var r=o.$wrapper.find('.wq-result[data-id="'+e.id+'"]');r.find(".indexWrapper").text(t+1),r.appendTo(o.$wrapper.find(".wq-results-list"))}),o.$wrapper.find(".wq-questions").fadeOut("slow",function(){o.$wrapper.find(".wq-results").fadeIn("slow")}),o.savePlayData(),o.$wrapper.off("click",".wq_retakeSwiperBtn",t),o.$wrapper.on("click",".wq_retakeSwiperBtn",t)}})}},{key:"savePlayData",value:function(){var e=s.restUrl+"wp-quiz/v2/play_data",t=s.helpers.getRequest({url:e,method:"POST",data:{quiz_id:this.quizId,quiz_data:JSON.stringify(this.quizData),answered:JSON.stringify(this.tracker),current_url:window.location.href}});t.done(function(e){console.log(e)}),t.fail(function(e){console.error(e)})}}]),e);function e(){return _classCallCheck(this,e),_possibleConstructorReturn(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}t(document).ready(function(){t(".wq-quiz-swiper").each(function(){var e=t(this).attr("data-quiz-id");void 0!==window["swiperQuiz"+e]&&new r(t(this),window["swiperQuiz"+e])})})}(wpQuiz,jQuery);